#include<iostream>
#include<string>
#include<vector>

#include "reader.h"

using namespace std;

void prepare_expected(vector<string>& expected) {
  expected.push_back(string("foo"));
  expected.push_back(string("bar"));
  expected.push_back(string("spam"));
}

void print_strv(vector<string>& got)
{
  cout << "\n==================\n";
  cout << "got leght is: " << got.size() ;
  for (vector<string>::iterator it = got.begin(); it != got.end(); it++ ) {
    cout << "\n* " << *it;
  }
  cout << endl;
}

void perform_test(string& input, vector<string>& expected)
{

  vector<string> got;
  got = read_line(input, string("|"));
  
  print_strv(got);
  
  if (expected == got) {
    cout << "\ntest went OK";
  } else {
    cout << "\ntest went bad";
  }
  cout << "\n==================\n";
}

void test_read_line() {

  string input("foo|bar|spam");
  vector<string> expected;
  prepare_expected(expected);

  perform_test(input, expected);
}


void test_read_line_other() {

  string input("foo");
  vector<string> expected;
  expected.push_back(string("foo"));

  perform_test(input, expected);
}





void test_reader()
{
  string delimiter("|");
  Reader* rdr = new Reader(cin, delimiter);
  vector<string> nxt = rdr->next();
  print_strv(nxt);
}
int main(int arg, char* argv[])
{

  test_read_line();
  test_read_line_other();

  test_reader();
  return 0;
}
